<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head th:fragment="head">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
		<!-- <link rel="stylesheet" type="text/css" media="all" th:href="@{/assets/admin/skins/base.css}" /> -->
		<link rel="stylesheet" type="text/css" media="all" th:href="@{/assets/admin/skins/default/style.css}" />
		<link rel="stylesheet" type="text/css" media="all" th:href="@{/assets/admin/skins/search.css}" />
		<link rel="stylesheet" type="text/css" media="all" th:href="@{/assets/css/pagination.css}" />
		<!-- <link rel="shortcut icon" th:href="@{/assets/images/favicon.ico}"> -->
		<link rel="stylesheet" type="text/css" media="all" th:href="@{/assets/scripts/flexigrid/css/flexigrid.pack.css}" />
		<script type="text/javascript" th:src="@{/assets/scripts/jquery/jquery-1.11.2.min.js}" ></script>
		<script type="text/javascript" th:src="@{/assets/scripts/flexigrid/js/flexigrid.js}"></script>
		<script type="text/javascript" th:src="@{/assets/admin/scripts/common.js}" ></script>
		<script type="text/javascript" th:src="@{/assets/libs/artDialog/jquery.artDialog.js?skin=default}"></script>
		<script type="text/javascript" th:src="@{/assets/libs/artDialog/artDialog.iframeTools.js}"></script>
	</head>
	<body>
		<!-- 面包屑导航 -->
		<div th:fragment="location(title)" class="location">
			<a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
			<a class="home" th:href="@{/}"><i></i>
			<span>首页</span></a> 
			<i class="arrow"></i> 
			<span th:text="${title}">型号管理</span>
		</div>
		<!--工具栏-->
		<div th:fragment="toolbar" class="toolbar-wrap">
			<div class="toolbar">
				<div class="box-wrap">
					<a class="menu-btn"></a>
					<div class="l-list">
						<ul class="icon-list">
							<!-- <li><a class="all" href="javascript:;" onclick="checkAll(this);"><i></i><span>全选</span></a></li> -->
							<li th:if="${permission!=null?(permission%4>1):true}"><a class="add" href="0"><i></i><span>新增</span></a></li>
							<!-- <li><a id="btnDelete" class="del"><i></i><span>删除</span></a></li> -->
						</ul>
					</div>
					<div class="r-list">
		                <input type="button" class="btn" onclick="$('#searchForm').toggle()" value="检索选项"/>
		            </div>
				</div>
			</div>
		</div>
		<!--/工具栏-->
		<table>
			<thead>
				<tr><th>名称</th><th>编号</th><th>是否上架</th><th>操作</th></tr>
			</thead>
			<tbody>
				<tr th:each="obj : ${page.content}">
					<td th:text="${obj.name}"></td>
					<td th:text="${obj.code}"></td>
					<td th:text="${obj.isOnsale}"></td>
					<td th:fragment="operation">
						<th:block th:if="${permission!=null?(permission%8>3):true}">
						<a th:href="*{id}">编辑</a>
						&nbsp;|&nbsp;
						</th:block>
						<a th:if="${permission!=null?(permission%16>7):true}" 
							th:href="'javascript:deleteObj('+*{id}+')'">删除</a>
					</td>
				</tr>
			</tbody>
		</table>
		<!--内容底部-->
		<div th:fragment="pagination(page)" th:object="${page}">
			<input type="hidden" name="page" th:value="*{number+1}" />
			<div class="line10"></div>
			<div class="pagelist">
			    <div class="l-btns">
			        <span>显示</span>
			        <input type="text" id="size" class="pagenum" th:value="*{size}" />
			        <span>条/页</span>
			    </div>
			    <div id="PageContent" class="default">
			        <span th:text="'共'+*{totalElements}+'条记录'">共13条记录</span>
			        <span id="prevPage" th:class="*{first}?disabled">«上一页</span>
			        <a th:remove="*{number &lt; 5}?all">1</a>
			        <span th:remove="*{number &lt; 6}?all">...</span>
			        <a th:text="*{number}-3" th:remove="*{number &lt; 4}?all"></a>
			        <a th:text="*{number}-2" th:remove="*{number &lt; 3}?all"></a>
			        <a th:text="*{number}-1" th:remove="*{number &lt; 2}?all"></a>
			        <a th:text="*{number}" th:remove="*{number &lt; 1}?all"></a>
			        <span class="current" th:text="*{number+1}">1</span>
			        <a th:text="*{number}+2" th:remove="*{number+2 &gt; totalPages}?all"></a>
			        <a th:text="*{number}+3" th:remove="*{number+3 &gt; totalPages}?all"></a>
			        <a th:text="*{number}+4" th:remove="*{number+4 &gt; totalPages}?all"></a>
			        <span th:remove="*{number+6 &gt; totalPages}?all">...</span>
			        <a th:text="*{totalPages}" th:remove="*{number+5 &gt; totalPages}?all"></a>
			        <span id="nextPage" th:class="*{last}?disabled">下一页»</span>
			    </div>
			</div>
		</div>
		<script th:fragment="indexscript" type="text/javascript">
			$("#list").flexigrid({
				height:window.innerHeight-220
			});
			$("input[type=submit]").click(function(){
				$("input[name=page]").val(1);
			});
			$("#PageContent a").click(function(){
				$("input[name=page]").val($(this).html());
				$("form").submit();
			});
			$("#size").blur(function(){
				var size=$("input[name=size]").val();
				if(!$.isNumeric($(this).val())){
					alert("请输入数字");
					$(this).val(size);
					return;
				}
				if($(this).val()!=size){
					$("input[name=size]").val($(this).val());
					$("form").submit();
				}
			});
			$("#prevPage").click(function(){
				if($(this).hasClass("disabled"))return;
				$("input[name=page]").val(parseInt($(".current").html())-1);
				$("form").submit();
			});
			$("#nextPage").click(function(){
				if($(this).hasClass("disabled"))return;
				$("input[name=page]").val(parseInt($(".current").html())+1);
				$("form").submit();
			});
			function deleteObj(id){
				if(confirm("确认删除?")) location.href=id+"/delete";
			}
		</script>
	</body>
</html>